home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / picture / ringpict.c < prev    next >
Text File  |  1993-09-23  |  2KB  |  93 lines

  1. //    Copyright 1993 Ralph Gonzalez
  2.  
  3. /*
  4. *    FILE:        ringpict.c
  5. *    AUTHOR:        R. Gonzalez
  6. *    CREATED:    November 7, 1990
  7. *
  8. *    Sample pict application.
  9. */
  10.  
  11. # include    "ringpict.h"
  12. # include    "ring.h"
  13.  
  14. /******************************************************************
  15. *    initialize
  16. ******************************************************************/
  17. Ring_Pict::Ring_Pict(void)
  18. {
  19.     Rotation_X        *rotx;
  20.     Translation        *transl;
  21.     Transformation    *combination;
  22.     
  23.     projector1 = new Projector;
  24.     projector1->set_background_color(BLUE);
  25.     projector1->set_cropping_frame(0.,-.05,1.,.5);
  26.     projector1->set_projection_frame(-.2,0.,1.4,.7);
  27.  
  28.     projector2 = new Corner_Projector;
  29.     
  30.     projector3 = new Projector;
  31.     projector3->set_background_color(YELLOW);
  32.     projector3->set_cropping_frame(0.,-.05,1.,.5);
  33.     projector3->set_projection_frame(.8,.15,.3,.8);
  34.     
  35.     projector1->set_screen(screen);
  36.     projector2->set_screen(screen);
  37.     projector3->set_screen(screen);
  38.     
  39.     camera1 = new Camera;
  40.     camera2 = new Camera;
  41.     camera2->set_position(0.,10.,10.,0.,PI/2.,0.);
  42.     
  43.     rotx = new Rotation_X;
  44.     rotx->set(-PI/12.);
  45.     transl = new Translation;
  46.     transl->set(0.,0.,10.);
  47.     combination = new Transformation;
  48.     combination->combine(rotx,transl);
  49.     
  50.     segment = new Ring;
  51.     segment->move(combination);
  52.     
  53.     delete rotx;
  54.     delete transl;
  55.     delete combination;
  56. }
  57.  
  58. /******************************************************************
  59. *    run
  60. ******************************************************************/
  61. void    Ring_Pict::run(void)
  62. {
  63.     Transformation    *identity;
  64.     
  65.     identity = new Transformation;
  66.     
  67.     segment->set_color(CYAN);
  68.     segment->draw(camera1,projector1,identity);
  69.     segment->set_color(GREEN);
  70.     segment->draw(camera2,projector2,identity);
  71.     segment->set_color(RED);
  72.     segment->draw(camera1,projector3,identity);
  73.  
  74.     screen->wait();
  75.     
  76.     delete identity;
  77. }
  78.  
  79. /******************************************************************
  80. *    destroy
  81. ******************************************************************/
  82. Ring_Pict::~Ring_Pict(void)
  83. {
  84.     delete projector1;
  85.     delete projector2;
  86.     delete projector3;
  87.  
  88.     delete camera1;
  89.     delete camera2;
  90.     
  91.     delete segment;
  92. }
  93.